/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package traffic.light.simulator.town.unity;

/**
 *
 * 
 */
class TownUnityType4 extends TownUnity {

    public TownUnityType4(int positionX, int positionY, int townSize) {
        super(CrossRoadType.TYPE_4, positionX, positionY, townSize);

    }

    @Override
    public void generateCorrespondantUnity() {
        super.generateCorrespondantUnity();

        townElements[0][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(0), RoadType.DOWN);
        townElements[0][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(0), RoadType.UP);
        townElements[1][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(1), RoadType.DOWN);
        townElements[1][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(1), RoadType.UP);
        townElements[2][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(2), RoadType.DOWN);
        townElements[2][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(2), RoadType.UP);
        townElements[3][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(3), RoadType.DOWN);
        townElements[3][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(3), RoadType.UP);
        townElements[4][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(4), RoadType.DOWN);
        townElements[4][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(4), RoadType.UP);
        townElements[5][2] = new RoadElement(absoluteElementXPosition(2), absoluteElementYPosition(5), RoadType.DOWN);
        townElements[5][3] = new RoadElement(absoluteElementXPosition(3), absoluteElementYPosition(5), RoadType.UP);
        generateAccessibleElements();
        generateTL();
    }

    @Override
    protected void generateAccessibleElements() {
        if (positionY == 0 || positionY == townSize - 1) {
            this.isAccessibleForMovableEntities = true;
            if (positionY == 0) {
                this.accessibleTownElement = townElements[0][2];
            } else if (positionY == townSize - 1) {
                this.accessibleTownElement = townElements[5][3];
            }
        }
    }
}
